package com.ms.game.bank.db;

import com.ms.game.bank.message.SBankPageResponse;
import com.ms.player.Player;
import com.ms.service.error.ErrorCode;
import com.ms.service.module.datacenterlite.CentralAsyncCommand;
import com.xpec.c4.db.dao.PlayerDAO;
import com.xpec.c4.game.utility.GUID;
import com.xpec.c4.message.MessageTypes;
import com.xpec.c4.service.message.MessageAction;

/**
 * 此async用在沒辦法把資料更新給zone的時候
 * 例如紅包
 * @author TW16028
 *
 */
public class loadBankGoldCoinDCLAsync extends CentralAsyncCommand {

	private static final long serialVersionUID = -11513285855446447L;
	
	public GUID playerID;
	
	public GUID sessionID;

	private Player player;
	
	@Override
	public void asyncExecute() throws Exception {
		player = PlayerDAO.loadPlayerByGuid(playerID);
	}

	@Override
	public void callBackExecute(Object... userData) throws Exception {
		Player playerData = (Player)userData[0];
		
		SBankPageResponse response = new SBankPageResponse(); 
		response.errorCode = ErrorCode.SUCCESS;
		response.bankGold = player.getBankGoldCoin().toString();
		MessageAction.sendMessage(sessionID, MessageTypes.S_BANK_INFO_RESPONSE, response);
		//將最新的值更新回zone
		playerData.setBankGoldCoin(player.getBankGoldCoin());
	}

}
